{{extend ('./layout')}}
{{#block ('head')}}
    <title>{{component}} test runner</title>
    <link rel="stylesheet" href="/kissy/tools/jasmine/jasmine.css">
    <link rel="stylesheet" href="/kissy/src/css/assets/dpl/base.css"/>
    <style>
        #TrivialReporter {
            position: static;
        }
        body {
            overflow-y: visible;
        }
    </style>
    <script>
        window.component = '{{{component}}}';
        window.travisJobId='{{{travisJobId}}}';
    </script>
    {{#each (externalLinks)}}
        <link rel="stylesheet" href="{{{this}}}"/>
    {{/each}}
    <style>
        {{{externalStyle}}}
    </style>
    {{set(suffix = '-debug')}}
    {{#if (query.min !== undefined)}}
        {{set(suffix = '')}}
    {{/if}}
    {{#if (query.loader !== undefined)}}
        <script src="/kissy/build/loader{{suffix}}.js"></script>
     {{else}}
        <script src="/kissy/build/seed{{suffix}}.js"></script>
    {{/if}}
    {{#if (query.coverage !== undefined)}}
        <script src="/kissy/tools/jscover/assets/jscoverage.js"></script>
    {{/if}}
    <script src="/kissy/src/package.js"></script>
    <script src="/kissy/tools/jasmine/jasmine.js"></script>
    <script src="/kissy/tools/jasmine/jasmine-html.js"></script>
    <script src="/kissy/tools/jasmine/jasmine.console_reporter.js"></script>
    <script src="/kissy/tools/jasmine/kissy-report.js"></script>
    <script src="/kissy/tools/jasmine/init.js"></script>
    <script src="/kissy/tools/jasmine/event-simulate.js"></script>
    <script>
        {{{externalScript}}}
        {{#if (query.coverage !== undefined)}}
            KISSY.config('packages')[component].filter = 'coverage';
        {{/if}}
    </script>
    {{#each (externalScripts)}}
        <script src="{{{this}}}"></script>
    {{/each}}
{{/block}}
{{#block ('body')}}
    <h1 style="text-align: center">{{component}} test cases</h1>
    {{{html}}}
    <script>
    window.xxx = (function(){
        function endsWith(str, suffix) {
            var ind = str.length - suffix.length;
            return ind >= 0 && str.indexOf(suffix, ind) === ind;
        }
        var tests = ['specs/'],
            S = KISSY;
        S.config('packages',{
            specs:{
                base: endsWith(location.pathname,
                        'runner')?'./specs':'../specs'
            },
            src:{
                base:'/kissy/src'
            }
        });

        {{#if (tests)}}
            tests.shift();
        {{/if}}

        {{#each (tests)}}
            tests.push('specs/{{{this}}}');
        {{/each}}

        {{{script}}}

        S.use(tests, function () {
            jasmine.getEnv().execute();
        });
    })();
    </script>
{{/block}}